package defpackage; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; import android.util.AttributeSet; import android.util.TypedValue; import android.view.View; import android.widget.ImageView; import java.io.IOException; import java.util.Arrays; import java.util.List; import pl.droidsonroids.gif.R; /* renamed from: abpc reason: default package */ public final class abpc { public static final List<String> CZW = Arrays.asList("raw", "drawable", "mipmap"); /* renamed from: abpc$a */ public static class a extends b { public final int CZX; public final int pm; a() { this.CZX = 0; this.pm = 0; } a(ImageView imageView, AttributeSet attributeSet, int i, int i2) { super(imageView, attributeSet, i, i2); this.CZX = a(imageView, attributeSet, true); this.pm = a(imageView, attributeSet, false); } private static int a(ImageView imageView, AttributeSet attributeSet, boolean z) { int attributeResourceValue = attributeSet.getAttributeResourceValue("http://schemas.android.com/apk/res/android", z ? "src" : "background", 0); if (attributeResourceValue > 0) { if (abpc.CZW.contains(imageView.getResources().getResourceTypeName(attributeResourceValue)) && !abpc.b(imageView, z, attributeResourceValue)) { return attributeResourceValue; } } return 0; } } /* renamed from: abpc$b */ public static class b { public boolean CZY; public int uCC; public b() { this.CZY = false; this.uCC = -1; } public b(View view, AttributeSet attributeSet, int i, int i2) { TypedArray obtainStyledAttributes = view.getContext().obtainStyledAttributes(attributeSet, R.styleable.GifView, i, i2); this.CZY = obtainStyledAttributes.getBoolean(R.styleable.GifView_freezesAnimation, false); this.uCC = obtainStyledAttributes.getInt(R.styleable.GifView_loopCount, -1); obtainStyledAttributes.recycle(); } } public static a a(ImageView imageView, AttributeSet attributeSet, int i, int i2) { if (attributeSet == null || imageView.isInEditMode()) { return new a(); } a aVar = new a(imageView, attributeSet, i, i2); int i3 = aVar.uCC; if (i3 < 0) { return aVar; } a(i3, imageView.getDrawable()); a(i3, imageView.getBackground()); return aVar; } public static void a(int i, Drawable drawable) { if (drawable instanceof abow) { ((abow) drawable).apJ(i); } } public static boolean a(ImageView imageView, Uri uri) { if (uri != null) { try { imageView.setImageDrawable(new abow(imageView.getContext().getContentResolver(), uri)); return true; } catch (IOException e) { } } return false; } static float b(Resources resources, int i) { TypedValue typedValue = new TypedValue(); resources.getValue(i, typedValue, true); int i2 = typedValue.density; if (i2 == 0) { i2 = 160; } else if (i2 == 65535) { i2 = 0; } int i3 = resources.getDisplayMetrics().densityDpi; if (i2 <= 0 || i3 <= 0) { return 1.0f; } return ((float) i3) / ((float) i2); } public static boolean b(ImageView imageView, boolean z, int i) { Resources resources = imageView.getResources(); if (resources != null) { try { abow abow = new abow(resources, i); if (z) { imageView.setImageDrawable(abow); } else if (Build.VERSION.SDK_INT >= 16) { imageView.setBackground(abow); } else { imageView.setBackgroundDrawable(abow); } return true; } catch (Resources.NotFoundException | IOException e) { } } return false; } }